{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入余额：88\n",
      "-----请选择编号，欢迎选购------\n",
      "商品编号1,商品名称奶茶,商品价格16\n",
      "商品编号2,商品名称中杯奶茶,商品价格17\n",
      "商品编号3,商品名称大杯奶茶,商品价格18\n",
      "请输入购买商品号：1\n",
      "【奶茶】已加入购物车，您的账户余额还剩【72】元\n"
     ]
    }
   ],
   "source": [
    "s=[\n",
    "    ['奶茶',16],\n",
    "    ['中杯奶茶',17],\n",
    "    ['大杯奶茶',18]\n",
    "]\n",
    "Alipay=int(input('请输入余额：'))\n",
    "while True:\n",
    "    print('-----请选择编号，欢迎选购------')\n",
    "    for i in range(len(s)):\n",
    "        print('商品编号%d,商品名称%s,商品价格%d'%(i+1,s[i][0],s[i][1]))\n",
    "    choice=int(input('请输入购买商品号：'))\n",
    "    if choice>s[choice-1][1]:\n",
    "        print('您选择的商品不存在')\n",
    "    else:\n",
    "        if Alipay>=s[choice-1][1]:\n",
    "            print('【%s】已加入购物车，您的账户余额还剩【%d】元'%(s[choice-1][0],Alipay-s[choice-1][1]))\n",
    "        else:\n",
    "            print('余额不足')\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
